// /*
//  * @Author: WanYiMing
//  * @Date:2024-07-25-18:16
//  * @Description:
//  */

using UnityEngine;

namespace Code.Monster
{
    public class MonsterManager : MonoBehaviour
    {
        [SerializeField]
        public int flashSpace;
        [SerializeField]
        public int leaderNum;
        [SerializeField]
        public int monsterNum;
        
        public void Start()
        {
            for (int i = 0; i < leaderNum; i++)
            {
                FlashLeader();
            }
            for (int i = 0; i < monsterNum; i++)
            {
                FlashMonster();
            }
        }

        private void FlashMonster()
        {
            GameObject mGameObject = (GameObject)Resources.Load("Monster");
            CreateObj(mGameObject);
        }

        private void CreateObj(GameObject mGameObject)
        {
            GameObject instantiate = Instantiate(mGameObject, transform, true);
            Vector2 randomPoint =
                new Vector2(Random.Range(-flashSpace, flashSpace), Random.Range(-flashSpace, flashSpace));

            instantiate.transform.position = randomPoint;
        }

        private void FlashLeader()
        {
            GameObject monsterLeader = (GameObject)Resources.Load("MonsterLeader");
            CreateObj(monsterLeader);
        }
    }
}